package net.butfly.bus.client;

import net.butfly.bus.client.config.ClientConfig;
import net.butfly.bus.config.Config;
import net.butfly.bus.router.DirectoryPolicy;
import net.butfly.bus.router.Router;
import net.butfly.bus.router.RouterBase;
import net.butfly.bus.router.RoutingPolicy;

class DefaultRouter extends RouterBase implements Router {
	public DefaultRouter(Config config) {
		super(config);
	}

	private ClientConfig config;

	@Override
	public String route(String tx, String version) {
		// param version is ignored at client.
		return this.route(tx);
	}

	@Override
	public String route(String tx) {
		String[] nodes = this.config.matchNodeId(tx);
		if (null == nodes)
			return null;
		switch (nodes.length) {
		case 0:
			return null;
		case 1:
			return nodes[0];
		default:
			return null;
		}
	}

	@Override
	protected DirectoryPolicy getDirectoryPolicy() {
		return null;
	}

	@Override
	protected RoutingPolicy getRoutingPolicy() {
		return null;
	}
}
